package com.kingmed.kmss.framework.stream.controller;

import com.kingmed.kmss.common.vo.CommonResponse;
import com.kingmed.kmss.common.vo.CommonResponseHelper;
import com.kingmed.kmss.framework.stream.mq.producer.DelayProducer;
import com.kingmed.kmss.framework.stream.mq.producer.LogStreamProducer;
import com.kingmed.kmss.framework.stream.mq.producer.MQProducer;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 测试mq
 */
@Slf4j
@AllArgsConstructor
@Api(tags = "mq临时测试")
@RequestMapping("/test-mq")
public class TestMqController {

    private final DelayProducer delayProducer;
    private final MQProducer testStreamProducer;
    private final LogStreamProducer logStreamProducer;

    /**
     * 测试发送延迟消息Rabbitmq
     *
     * @param msg 消息内容
     * @param delay 延时时间
     */
    @GetMapping("/sendRabbitmq")
    public CommonResponse<Void> sendRabbitmq(String msg, Long delay) {
        delayProducer.sendMsg(msg, delay);
        return CommonResponseHelper.success();
    }

    /**
     * 测试发送消息Rocketmq
     *
     * @param msg 消息内容
     */
    @GetMapping("/sendRocketmq")
    public CommonResponse<Void> sendRocketmq(String msg) {
       // testStreamProducer.streamTestMsg(msg);
        return CommonResponseHelper.success();
    }

    /**
     * 测试发送消息Kafka
     *
     * @param msg 消息内容
     */
    @GetMapping("/sendKafka")
    public CommonResponse<Void> sendKafka(String msg) {
        logStreamProducer.streamLogMsg(msg);
        return CommonResponseHelper.success();
    }

}
